package com.richardjaap.jersey;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.richardjaap.data.Account;
import com.richardjaap.data.Lobby;
import com.richardjaap.data.TableInfo;

@Path("/lobby")
public class LobbyResource {
	
	

	@GET
	@Path("/tableInfo/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public TableInfo getTableInfo(@PathParam("id") int id){
		TableInfo info = Lobby.getInstance().getTableInfo(id);
		return info;
				//"id: " + info.getTableId() + "\nAmount of Players: " + info.getAmountOfPlayers() + "\nPlayer: " + info.getPlayers().get(0).getUsername();
	}
	
	@GET
	@Path("/login")
	@Produces(MediaType.APPLICATION_JSON)
	public Account login(@QueryParam("username") String username, @QueryParam("password") String password){
		System.out.println("username: " + username);
		Account account = Lobby.getInstance().logIn(username, password);
		if(account != null){
			return account;
		}
		return null;
	}
}
